"""
自动管理cookie：
1. requests.get、requests.post 这种方式不会管理cookie
2. session的机制，创建一个session，用session发送请求，这种情况下，会自动管理cookie
"""

import requests

s = requests.Session()  # 创建一个session
print("=================登录前=================")
print("登录前：", s.cookies)
url = "https://www.bagevent.com/user/login"
cs = {"access_type": "1",
      "loginType": "1",
      "emailLoginWay": "0",
      "account": "2780487875@qq.com",
      "password": "qq2780487875",
      "remindmeBox": "on",
      "remindme": "1"}
r = s.post(url, data=cs)
# print(r.text)
print("=================登录后=================")
print("登录后：", s.cookies)

url = "https://www.bagevent.com/account/dashboard"
r = s.get(url)
# print(r.text)

print("================退出登录后==============")
url = "https://www.bagevent.com/user/login_out"
r = s.get(url)
# print(r.text)
print("退出登录后：",s.cookies)